<template>
  <footer class="footer">
    <span class="todo-count"
      >剩余<strong>数量值{{ sy }}</strong></span
    >
    <ul class="filters">
      <li>
        <a
          :class="{ selected: gaoliang === 'all' }"
          @click="check('all')"
          href="javascript:;"
          >全部</a
        >
      </li>
      <li>
        <a
          href="javascript:;"
          :class="{ selected: gaoliang === 'wei' }"
          @click="check('wei')"
          >未完成</a
        >
      </li>
      <li>
        <a
          href="javascript:;"
          :class="{ selected: gaoliang === 'yi' }"
          @click="check('yi')"
          >已完成</a
        >
      </li>
    </ul>
    <button v-show="show" class="clear-completed" @click="qingchu">
      清除已完成
    </button>
  </footer>
</template>

<script>
export default {
  data() {
    return {
      gaoliang: "all",
    };
  },

  props: ["list"],
  computed: {
    sy() {
      return this.list.filter((item) => !item.isDone).length;
    },
  },
  methods: {
    check(a) {
      this.gaoliang = a;
      this.$emit("check", a);
    },
    qingchu() {
      this.$emit("qingchu");
    },
    show() {
      return this.list.some((item) => item.isDone);
    },
  },
};
</script>
